import request from "../pulgins/umi-request";
export const queryLogin = async ({ username, password }) => {

    // if (校验输入合法性,依赖封装的utils库){
    if (true) {

        let params = new URLSearchParams();
        params.append('username', username);
        params.append('password', password);

        // return request.get(`/api/login`,{params:{username,password}})
        return request.get(`/api/login`, { params })
    } else {
        return Promise.reject('输入不合法')
    }

};

export const queryReg = async ({ username, password, icon }) => {

    // icon 要求是个files 原生
    // if (校验输入合法性,依赖封装的utils库){
    if (true) {

        //针对3000
        /*let data = new FormData();
        data.append('username',username);
        data.append('password',password);
        if(icon.files.length>0){
          data.append('icon',icon.files[0]);
        }
    
        // return request.get(`/api/login`,{params:{username,password}})
        return request(`/api/reg`,{method:'post',data})*/


        //针对3333

        let params = new URLSearchParams();
        params.append('username', username);
        params.append('password', password);

        // return request.get(`/api/login`, { params: { username, password } })
        return request(`/api/reg`, { method: 'post', data: params })


    } else {
        return Promise.reject('输入不合法')
    }

};

//提供给路由守卫
export const queryAutoLogin = async () => request.get('/api/islogin')


export const queryUser = async () => request.get('/api/user')